package com.Jano.dao.Impl;

import com.Jano.dao.QuestionnaireDao;
import com.Jano.entity.Questionnaire;

import java.util.List;

/**
 * description: QuestionnaireImpl <br>
 * date: 2022/6/6 3:59 PM <br>
 * author: zoumaoji <br>
 * version: 1.0 <br>
 */
public class QuestionnaireDaoImpl extends AbstractDaoImpl implements QuestionnaireDao {
    @Override
    public void CreateQuestionnaire(int userId, String title) {
      update("insert into t_questionnaire (user_id,title) values(?,?)",new Object[]{userId,title});
    }

    @Override
    public Questionnaire selectQuestionnaireIdByTitle(String title) {
        return queryForObject("select id questionnaireId,title,user_id userId from t_questionnaire where title=?",Questionnaire.class,new Object[]{title});
    }

    @Override
    public List<Questionnaire> selectQuestionnaireByUserId(int userId) {
        return queryForList("select id questionnaireId,title,user_id userId from t_questionnaire where user_id=?",Questionnaire.class,new Object[]{userId});
    }
}
